<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
	body{
		margin: 0;
		padding: 0;
	}
	</style>
</head>
<body>
	<input type="button" id="btn" value="点击"/>
	<br>
	<img src="img/a.jpg" width="400" height="300" alt="" id="img">
	<script>
	var btn = document.getElementById('btn')
	var img = document.getElementById('img')
	var flag = 1;
	btn.onclick = function(){
		if(flag == 1){
		img.src='img/a.jpg';
		flag = 2;
	}else if(flag == 2){
		img.src='img/b.jpg';
		flag = 1;
	}
	}
	</script>
</body>
</html>